/**
 * Creared with IntelliJ IDEA.
 * Description:静态内部类
 * User:yxd
 * Date:2022-02-28
 * Time:19:42
 */
class Outclass1 {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;
    //静态内部类
    static class InnerClass{
        public int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6;//可以定义静态的变量不需要外部类对象
        public void test(){
            //System.out.println(data1);//需要外部类对象的引用来调用
           // System.out.println(data2);
            System.out.println(new Outclass1().data1);
            System.out.println(new Outclass1().data2);//在内部类建一个对象也可以
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);

            System.out.println("test()");
        }
    }
}
public class Test2 {
    public static void main(String[] args) {
        //获取静态内部类的对象
        Outclass1.InnerClass innerClass = new Outclass1.InnerClass();//不需要再创建外部类对象了
        innerClass.test();
    }


}
